package com.solr.server;

import org.apache.solr.client.solrj.impl.CloudSolrClient;

public class SolrCoudServer {
	private CloudSolrClient server;
	private SolrCoudServer(){
		String zkHost = "localhost:2181,localhost:2182,localhost:2183";
		String defaultConllection = "product_core";
		int zkClientTimeout = 20000;
		int zkConnectTimeout = 1000;
		@SuppressWarnings("deprecation")
		CloudSolrClient cloudSolrClient = new CloudSolrClient(zkHost);
		cloudSolrClient.setDefaultCollection(defaultConllection);
		cloudSolrClient.setZkClientTimeout(zkClientTimeout);
		cloudSolrClient.setZkConnectTimeout(zkConnectTimeout);
		cloudSolrClient.connect();
		server =  cloudSolrClient;
	
	}
	
	private static class Holder{
		private static final SolrCoudServer SOLR_COUD_SERVER = new SolrCoudServer();
	}
	
	public static final SolrCoudServer getInstance(){
		return Holder.SOLR_COUD_SERVER;
	}
	
	public CloudSolrClient getServer() {
		return server;
	}

}
